package cn.sh.yhk.config;

import cn.sh.yhk.acl.mapper.UserMapper;
import cn.sh.yhk.acl.service.UserInfoService;
import cn.sh.yhk.file.service.MinioService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.redisson.api.RedissonClient;

import java.lang.reflect.Method;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
 * @Classname Yhk
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/10/12 14:32
 * @Created by y6522
 */
@Slf4j
@Component
public class StartupConfig implements ApplicationRunner {
    @Autowired
    @Qualifier("requestMappingHandlerMapping")
    private RequestMappingHandlerMapping handlerMapping;

    //    @Autowired
//    RedisCacheUtils redisCacheUtils;
    @Autowired
    MinioService minioService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        printRequestMappings();
        minioService.createBucket("asas");
    }


    /**
     * 打印出项目中所有的url请求地址和方法的映射关系
     */
    public void printRequestMappings() {
        Map<RequestMappingInfo, HandlerMethod> handlerMethods = handlerMapping.getHandlerMethods();
        for (Map.Entry<RequestMappingInfo, HandlerMethod> entry : handlerMethods.entrySet()) {
            RequestMappingInfo info = entry.getKey();
            log.info("URL Path: {}", info.toString());
        }
    }


}
